<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		
		<meta name="description" content="小霸王在线玩，品位经典">
		<meta name="keywords" content="小霸王在线玩，fc，nes，在线小霸王游戏">
		<meta name="robots" content="index, follow">
		  
		<meta name="author" content="IT_迁哥">
		<title>千千万能工具箱-在线小霸王游戏</title>
	</head>
	<body>
		
		<div id="app">
			<div style="text-align: center;"><img src="https://lqcpws.cn/tinyfile/1698732165394-169873207551975.png" />
			</div>
			<div style="text-align: center;">
				<el-input id="name" placeholder="请输入游戏名称" style="width: 10%;"></el-input>
				&nbsp;&nbsp;&nbsp;
				 <el-button @click="search()">搜索</el-button>

			</div>
			<br/>
			<div style="width: 70%;margin: auto;">
				<div v-for="(item,index) in showData">
					<el-row :gutter="20">
						<el-col :span="6" v-for=" (zitem,zindex) in item" style="cursor: pointer;">
							<div @click="openGame(zitem.id)" class="grid-content bg-purple" style="text-align: center;">
								<img :id="index+'_'+zindex" :src="getBase64Data(zitem.gameImg,index+'_'+zindex)"
									width="500" width="500" /></div>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="6" v-for=" zitem in item" style="cursor: pointer;">
							<div @click="openGame(zitem.id)" class="grid-content bg-purple"
								style="text-align: center; font-weight: bold;color: lightslategray;">{{zitem.name}}
							</div>
						</el-col>
					</el-row>
					<br />
				</div>

				<div style="text-align: center;">
					<el-pagination @current-change="currentPage" layout="prev, pager, next,total" :background="true"
						:page-size="limit" :current-page.sync="page" :total="total">
					</el-pagination>
				</div>
			</div>
		</div>
	</body>

	<script src="../../js/jquery.min.js"></script>
	<script src="../../js/vue2.6.11/vue.js"></script>
	<link rel="stylesheet" href="../../js/element2.4.7/index.css" />
	<script src="../../js/element2.4.7/index.js"></script>
	<script>
		const baseUrl = "https://api.lqcpws.cn"
		// const baseUrl = "http://192.168.1.121:8848"

		// const gameUrl = "http://192.168.1.121:10001/qqgjx-private-nes/index.html?id="
		
			const gameUrl = "https://www.lqcpws.cn/nes/index.html?id="
		const app = new Vue({
			el: '#app',
			data: {

				title: '',
				sourceData: [],
				showData: [],
				name: "",
				page: 1,
				limit: 20,
				total: 0,

			},
			mounted() {
				$.ajax({
					type: 'get',
					url: baseUrl + "/pc/requestCountByDay",
					success: function(res) {


					}
				})
				this.pageData()


		this.$notify({
					title: '提示',
					message: '1：在线小霸王游戏2000款免费玩，支持存档<br/>' +
						'2：截图不全，大家玩的时候可以补充<br/>' +
						'3：有些玩不了，引擎不支持！<br/>' +
						'4：后续会支持更多引擎！',
					dangerouslyUseHTMLString: true,
					duration: 10000,
					type: 'warning'
				});
			},
			methods: {
				search(){
					this.name=document.getElementById('name').value
					this.page=1
					this.pageData()
				},
				getBase64Data(url,zindex) {
					let data = undefined
					$.ajax({
						async: true,
						url: url==undefined?'https://lqcpws.cn/tinyfile/1698735727254.txt':url,
						success(res) {
							document.getElementById(zindex).src=res
						}

					})
			
				},
				openGame(id) {
					window.open(gameUrl + id, '_blank')
				},
				currentPage(value) {
					this.page = value
					this.pageData()
				},
				splitList(data, limit) {
					let size = data.length % limit == 0 ? data.length / limit : parseInt(data.length / limit) + 1
					let dataArray = []
					let start = 0
					for (let i = 0; i < size; i++) {
						let tempArray = []
						for (let j = 0; j < limit; j++) {
							if (start < data.length) {
								tempArray.push(data[start++])
							} else {
								break;
							}
						}
						dataArray.push(tempArray)
					}
					return dataArray;
				},
				pageData() {
					let _this = this
					$.ajax({
						type: 'get',
						url: baseUrl + "/pc/nesGame/getNesGamePage",
						data: {
							page: _this.page,
							limit: _this.limit,
							name: _this.name
						},
						success: function(res) {
							_this.sourceData = res.data
							_this.total = res.total
							_this.showData = _this.splitList(_this.sourceData, 4)


						}
					})

				},



			}
		})
	</script>
</html>
